You use a color table, which is defined by a data structure of type ColorTable , to specify colors in the form of RGBColor records. You can create and store color tables in 'clut' resources. To retrieve a color table stored in a 'clut' resource, you can use the GetCTable function. To dispose of the handle allocated for a color table, you use the DisposeCTable procedure.
The Palette Manager, described in the chapter "Palette Manager" in Inside Macintosh: Advanced Color Imaging , has additional routines that enable you to copy colors between palettes and color tables and to restore the default colors to a CLUT belonging to a graphics device.
The Color Manager, described in the chapter "Color Manager" in Inside Macintosh: Advanced Color Imaging , contains low-level routines for directly manipulating the fields of the CLUT on a graphics device; most applications do not need to use those routines.
To get a color table stored in a 'clut' resource, use the GetCTable function.
FUNCTION GetCTable (ctID: Integer): CTabHandle;
For the color table defined in the 'clut' resource that you specify in the ctID parameter, the GetCTable function returns a handle to a ColorTable record. If the 'clut' resource with that ID is not found, GetCTable returns NIL .
If you place this handle in the pmTable field of a PixMap record, you should first use the DisposeCTable procedure to dispose of the handle already there.
If you modify a ColorTable record, you should invalidate it by changing its ctSeed field. An easy way to do this is with the CTabChanged procedure, described on CTabChanged .
The GetCTable function recognizes a number of standard 'clut' resource IDs. You can obtain the default grayscale color table for a given pixel depth by calling GetCTable , adding 32 (decimal) to the pixel depth, and passing this value in the ctID parameter, as shown in Table 4-5 .
For full color, you can obtain the default color tables by adding 64 to the pixel depth and passing this in the ctID parameter, as shown in Table 4-6 . These default color tables are illustrated in Plate 1 at the front of this book.
The GetCTable function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.
The 'clut' resource is described on The Color Table Resource .
Use the DisposeCTable procedure to dispose of a ColorTable record. The DisposeCTable procedure is also available as the DisposCTable procedure.
PROCEDURE DisposeCTable (cTable: CTabHandle);